package org.abacus.platform.database.impl;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

import org.abacus.http.HttpRequest;
import org.abacus.model.sys.Role;
import org.abacus.model.sys.User;
import org.abacus.platform.core.util.Page;
import org.abacus.platform.database.Database;
import org.junit.Test;

public class DatabaseTest {

	@Test
	public void database() {
		Database db = Database.getInstance();
		System.out.println(db);
	}

	@Test
	public void getString() {
		String url = "http://127.0.0.1:8080/chaoyangli.abacus/api/menu/list.json";
		HttpRequest r = new HttpRequest(url);
		Map<String, Object> m = new HashMap<String, Object>();
		m.put("page", new Page());
		System.out.print(r.getJson(m));
	}

	@Test
	public void roles() {
		String url = "http://127.0.0.1:8080/chaoyangli.abacus/api/userRole/roles.json";
		HttpRequest r = new HttpRequest(url);
		Map<String, Object> m = new TreeMap<String, Object>();
		User entity = new User();
		entity.setId("{fef1bbf7-62af-4bc1-a59b-8de4d82c25de}");
		m.put("user", entity);
		m.put("levelNumber", 1);
		m.put("userRoleValid", true);
		m.put("roleValid", true);
		System.out.print(r.getJson(m));
	}

	@Test
	public void menus() {
		String url = "http://127.0.0.1:8080/chaoyangli.abacus/api/roleMenu/menus.json";
		HttpRequest r = new HttpRequest(url);
		Map<String, Object> m = new TreeMap<String, Object>();
		Role entity = new Role();
		entity.setId("{e102f71f-204f-4069-8496-8d583b882b7b}");
		m.put("role", entity);
		m.put("levelNumber", 1);
		m.put("roleMenuValid", true);
		m.put("menuValid", true);
		System.out.print(r.getJson(m));
	}
}
